package com.jxw.utils;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.util.Log;
import java.util.List;

/* loaded from: classes.dex */
public class CommonUtil {
    public static final int DISABLE_EXPAND = 65536;
    public static final int DISABLE_NONE = 0;
    private static final int MIN_CLICK_DELAY_TIME = 1000;
    private static long lastClickTime;

    public static int px2sp(Context context, float f) {
        return (int) ((f / context.getResources().getDisplayMetrics().scaledDensity) + 0.5f);
    }

    public static Intent createExplicitFromImplicitIntent(Context context, Intent intent) {
        List<ResolveInfo> queryIntentServices = context.getPackageManager().queryIntentServices(intent, 0);
        Log.e("zzj", "resolveInfo=" + queryIntentServices);
        if (queryIntentServices == null || queryIntentServices.size() == 0) {
            return null;
        }
        ResolveInfo resolveInfo = queryIntentServices.get(0);
        String str = resolveInfo.serviceInfo.packageName;
        ComponentName componentName = new ComponentName(str, resolveInfo.serviceInfo.name);
        Log.e("zzj", "packageName=" + str);
        Intent intent2 = new Intent(intent);
        intent2.setComponent(componentName);
        return intent2;
    }

    public static String getBookRecordKey(String str) {
        String str2 = null;
        if (str == null) {
            return null;
        }
        if (str != null && str.startsWith("d:")) {
            String[] split = str.split("\\|");
            for (int i = 0; i < split.length; i++) {
                if (split[i] != null && split[i].length() > 2 && split[i].startsWith("d:")) {
                    str2 = split[i].substring(2);
                }
            }
        }
        return str2;
    }

    public static boolean isFastClick() {
        long currentTimeMillis = System.currentTimeMillis();
        boolean z = currentTimeMillis - lastClickTime >= 1000;
        lastClickTime = currentTimeMillis;
        return z;
    }

    public static void disableStatusBars(Context context) {
        try {
            Class.forName("android.app.StatusBarManager").getMethod("disable", Integer.TYPE).invoke(context.getSystemService("statusbar"), 65536);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void enableStatusBars(Context context) {
        try {
            Class.forName("android.app.StatusBarManager").getMethod("disable", Integer.TYPE).invoke(context.getSystemService("statusbar"), 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
